package org.springframework.archiesean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * 后置处理器
 *
 * @author ArchieSean
 * @create 2023/7/28
 */
public class MyBeanPostProcess implements BeanPostProcessor {
	public MyBeanPostProcess() {
		System.out.println("BeanPostProcessor实现类的构造函数...");
	}

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		if ("myBean".equalsIgnoreCase(beanName)) {
			System.out.println("BeanPostProcessor实现类postProcessBeforeInitialization方法被调用...");
		}
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		if ("myBean".equalsIgnoreCase(beanName)) {
			System.out.println("BeanPostProcessor实现类postProcessAfterInitialization方法被调用...");
		}
		return bean;
	}
}
